﻿using System;
using Kiva7.Utilities;
using Kiva7.DataResponse;
using Kiva7.DataClasses;
using Kiva7.Baskets;

namespace Kiva7.DataRequests
{
        public class LoanDetailRequest : DataRequest<LoansResponse, Loan>
    {
            public LoanDetailRequest()
            : base(true, true)
        {
        }


        public Uri BuildUri(int loanId)
        {
            UrlCreator url = new UrlCreator(string.Format(BaseUrl + "loans/{0}.xml", loanId));

            url.Add("app_id", KivaAppId);

            return url.ToUri();
        }


        internal void GetLoan(int loanId)
        {
            LoadResponse(BuildUri(loanId));
        }

        protected override void CopyResponse(LoansResponse response)
        {
            base.CopyResponse(response);
            if (SingleData != null)
            {
                SingleData.IsSelected = Basket.Current.Contains(SingleData.Id);
            }
        }

    }

}
